<div class="layui-fluid" id="VIEW-list-table" lay-title="批量导入">
   	<form class="layui-form" lay-filter="lig-tplForm" style="margin-top:10px;">
   		<input type="hidden" name="name" value="客户数据导入模板" />
   		<input type="hidden" name="url" id="tplUrl" value="" />
   		<input type="hidden" name="importUrl" id="importUrl" value="" />
    
    <div class="layui-row" style="margin-bottom:10px;">
         <div class="layui-form-item" style="margin-bottom:0;">
          <div class="layui-inline">
                <label class="layui-form-label">时间标签</label>
                <div class="layui-input-inline">
                    <select name="timeTag">
                    </select>
                </div>
            </div>
         </div>
    </div>
		<div class="layui-row">
   			<div class="layui-col-md5">
   				<div style="text-align:center;">
   					<div class="layui-form-item">
   						1、下载模板，填写信息
   					</div>
   					<div class="layui-form-item">
   						<i class="layui-icon layui-icon-list" style="font-size:70px;color: #73d13d;"></i>
   					</div>
   					<div class="layui-form-item">
   						<button class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="lig-tpl-download">下载模板</button>
   					</div>
   				</div>
   			</div>
   			<!-- <div class="layui-col-md4">
   				<div style="text-align:center;">
   					<div class="layui-upload">
   						<div class="layui-form-item">
	   						2、小数据量导入
	   					</div>
	   					<div class="layui-form-item">
	   					</div>
	   					<div class="layui-form-item">
	   						<i class="layui-icon layui-icon-list" style="font-size:70px;color: #73d13d;"></i>
	   					</div>
   						<div class="layui-form-item" style="margin-bottom:10px;">
   							<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="test8">选择文件</button>
   						</div>
   						<div class="layui-form-item">
   							<button type="button" class="layui-btn" id="test9">
   								<i class="layui-icon layui-icon-upload"></i>导入
   							</button>
   						</div>
					</div>
   				</div>
   			</div> -->
        <div class="layui-col-md5">
          <div style="text-align:center;">
            <div class="layui-upload">
              <div class="layui-form-item">
                2、数据量导入
              </div>
              <div class="layui-form-item">
              </div>
              <div class="layui-form-item">
                <i class="layui-icon layui-icon-list" style="font-size:70px;color: #73d13d;"></i>
              </div>
              <div class="layui-form-item" style="margin-bottom:10px;">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="test1">选择文件</button>
              </div>
              <div class="layui-form-item">
                <button type="button" class="layui-btn" id="test2">
                  <i class="layui-icon layui-icon-upload"></i>导入
                </button>
              </div>
          </div>
          </div>
        </div>
   		</div>
    </form>
</div>
<script>
    var selectedTenantId;
    layui.use(['jquery', 'lig', 'conf', 'upload'], function ($, lig, conf, upload) {
      var _dataForm = '[lay-filter="lig-tplForm"]';

      lig.loadSelectDict('bu_customer_time_tag', _dataForm + ' select[name="timeTag"]', true);

    	$('[lay-filter="lig-tpl-download"]').click(function(){
    		lig.export('[lay-filter="lig-tplForm"]', 'setting/file/download');
    	});

    	upload.render({
		    elem: '#test8'
		    ,url: conf.requestUrl + $('#importUrl').val()
		    ,accept: 'file'
		    ,auto: false
		    ,bindAction: '#test9'
		    ,before: function() {
		    	lig.load();
		    }
		    ,done: function(result){
		    	lig.unload();
		    	lig.ajaxresult(result, {
            success: function(result) {
              if (result.message != null && result.message != '') {
                lig.alert(result.message);
              } else {
                lig.success();
              }
            }
          });
		    }
		});
      upload.render({
        elem: '#test1'
        ,url: conf.requestUrl + '/setting/file/upload'
        ,accept: 'file'
        ,auto: false
        ,bindAction: '#test2'
        ,before: function() {
          lig.load();
        }
        ,done: function(result){
          lig.unload();
          lig.ajaxresult(result, {
            success: function(rese) {
              if (rese.data) {
                  var fileUrl = rese.data[0].fileUrl;
                  lig.ajaxpost({
                    url: 'bu/customer/importExcelWithBigData',
                    data: {
                      fileUrl: fileUrl,
                      timeTag: $(_dataForm + ' select[name="timeTag"]').val()
                    },
                    success: function(res) {
                      if (res.message != null && res.message != '') {
                        lig.alert(res.message);
                      } else {
                        lig.success();
                      }
                    }
                  });
                }
              
            }
          });
        }
      });
        
    });
</script>